//
//  GoodsModel.swift
//  OnceNectar
//
//  Created by yanghao on 15/05/2018.
//  Copyright © 2018 com.inwhoop. All rights reserved.
//

import Foundation
import MappingAce
import SwiftyJSON

struct GoodsModel:Mapping {
    var goodsDescribe :String?
    var coverPath :String?
    var updateTime :String?
//    var label :String?
    var type :String?
    var goodsAlias :String?
    var labelId :String?
    var createTime :String?
    var inventorySum :String?
    var stick :String?
    var id :String?
    var jointId :String?
    var goodsName :String?
    var picAddress :String?
    var status :String?
    var payNum :String?
    var coverHeight: String?
    var coverWidth: String?
    var shareUrl: String?
    var contentUrl: String?
    var telephone: String?
    
    var collected: String?
    
    var fileInfos:[FileInfoModel]?
    var specifications:[SpecificationsModel]?
    var label:InterestMarkModel?
    
}


extension GoodsModel{
    mutating func initFileInfos(arr: [JSON]) {
        
        var xlabers :[FileInfoModel] = []
        for object in arr {
            
            let xmodel = FileInfoModel(fromDic: object.dictionary! )
            
            xlabers.append(xmodel)
        }
        fileInfos = xlabers
    }
    
    mutating func initSpecifications(arr: [JSON]) {
        
        var xlabers :[SpecificationsModel] = []
        for object in arr {
            
            let xmodel = SpecificationsModel(fromDic: object.dictionary! )
            
            xlabers.append(xmodel)
        }
        specifications = xlabers
    }
    
    mutating func initLabel(dic: [String:Any]) {
        
        label = InterestMarkModel(fromDic: dic)
    }
   
}
